import Page
from Page import Yomi
from Base.Base import Base
from selenium.webdriver.common.by import By


class YomiPassagePage(Base):
    """
    语音训练一段话页(录音页)

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的返回键
        self.passage_back_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format('ivBack'))

        # 左侧的home键
        self.passage_home_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format('ivHome'))

        # 一段话标题
        self.passage_title_text = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("textView6"))

        # 语音图标
        self.passage_voice_btn = (By.XPATH, Yomi.RESOURCE_ID.format("iv_recording"))

        # 开始录音按钮
        self.passage_start_voice_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("btn_record"))

        # 确认按钮
        self.passage_sure_btn = (By.XPATH, Yomi.RESOURCE_ID.format("btn_sure"))

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.passage_back_btn)

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.passage_home_btn)

    def get_title(self):
        """
        获取录音标题

        :return:获取元素
        """
        return self.find_element_o(self.passage_title_text)

    def get_voice(self):
        """
        获得语音输入图标

        :return:None
        """
        return self.find_element_o(self.passage_voice_btn)

    def click_start_voice(self):
        """
        获得语音输入图标

        :return:None
        """
        self.click_element(self.passage_start_voice_btn)

    def get_sure(self):
        """
        获取确认按钮属性

        :return:获取元素
        """
        return self.find_element_o(self.passage_sure_btn)

    def click_sure(self):
        """
        点击确认按钮

        :return:None
        """
        self.click_element(self.passage_sure_btn)

    def is_display_yomi_voice(self):
        """
        查看是否进入录音页

        :return:
        """
        return self.is_display(self.passage_voice_btn)
